<style type="text/css">
body{background:#eee}
.storelogo img{width:3.2rem;height:3.2rem}
.merchgroup .store-star {padding:0.1rem 0 0.2rem 0;font-size:0.55rem;line-height:1rem}
.merchgroup .store-star img{height:0.66rem}
.star-on,.star-off{position:absolute;top:1rem;left:0;overflow:hidden}
.star-rate {margin-left:3.6rem}
.store-distance{float:right;color:#999}
.store-moneylimit{font-size:0.55rem}
.fui-number .minus:before, .fui-number .plus:before {
	border-left: 0 solid #d9d9d9;
}
.fui-number .minus:after, .fui-number .plus:after {
	border-right: 0 solid #d9d9d9;
}
.fui-number:before {
	border-top: 0 solid #d9d9d9;
}
.fui-number:after {border-top: 0 solid #d9d9d9;}
.fui-number .num {
	color:#666;
}
.fui-number .num {
	color:#666;
}
.fui-number.small {
	height: 1.2rem;
	width: auto;
	line-height: 1.2rem;
}
.fui-number .minus, .fui-number .plus {
	z-index:0;
}
.fui-number.small .minus{
	color: {{main.syscolor || '#63BE72'}};
	padding-top:1px;
	border: 1px solid {{main.syscolor || '#63BE72'}};
	border-radius:50%;
}
 .fui-number.small .plus {
	color: #fff;
	padding-top:1px;
	background: {{main.syscolor || '#63BE72'}};
	border: 1px solid {{main.syscolor || '#63BE72'}};
	border-radius:50%;
}
.fui-btn-c {
    height: auto;
    margin: 0;
    padding: 0.4rem;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
	justify-content:center;
    align-items: center;
    position: relative;
}

.fui-btn-c .icon {
	font-size:1rem;
	padding-right:0.3rem;
	text-align:right;
}

.fui-btn-c .info {
	text-align:left;
    padding-right: 0.2rem;
    font-size: 0.75rem;
}

.fui-btn-c .info p {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
.jylabel-red-0.active::after{content:" ";width:23px;height:24px;background:url(../core/resource/images/promotion-bg.png) 0 -159px no-repeat;position:absolute;float:right;right:-1px;bottom:-1px;text-align:center;background-color:#fce9e9;}

</style>
<div class="fui-page order-create-page fui-page-current" ng-if="pagedata.op == 'buyanimal'">
	 <div class="fui-header">
		<div class="fui-header-left" ng-click="goback()">
            <a class="back"></a>
        </div>
		<div class="title">领养家禽</div>
		<div class="fui-header-right"></div>
	</div>
	<div class="fui-content">
		<div ng-include="sys_html('_peisong')"></div>
		<div class="jy-content">
		<div class="weui_cells" style="margin-top:0">
		<div class="weui_cell">
                <div class="weui_cell_hd weui_cell_primary" style="padding:0.3rem 0">
                    <span>家禽名称</span>
                </div>
                <div class="weui_cell_ft">{{pagedata.animal.title}}</div>
        </div>
		<div class="weui_cell">
                <div class="weui_cell_hd weui_cell_primary"  style="padding:0.3rem 0">
                    <span>家禽分类</span>
                </div>
                <div class="weui_cell_ft">{{pagedata.aclassify.title}}</div>
        </div>
		<div class="weui_cell">
                <div class="weui_cell_hd weui_cell_primary"  style="padding:0.3rem 0">
                    <span>单价费用</span>
                </div>
                <div class="weui_cell_ft">{{pagedata.animal.price}}元</div>
        </div>
		<div class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label">认养数量</label></div>
                <div class="weui_cell_hd weui_cell_primary">
                    <span class="fui-number small r-f" style="right:0;margin-top:0.3rem">
						<span class="minus" ng-click="pagedata.cart_minus()"><i class="icon icon-subtract" style="font-size:0.7rem"></i></span>
							<input ng-if="pagedata.post.total>0" class="num shownum" type="text" ng-model="pagedata.post.total" style="width:1rem" ng-change="pagedata.cart_refresh()"/>
						<span class="plus" ng-click="pagedata.cart_plus()"><i class="icon icon-tianjia" style="font-size:0.7rem"></i></span>
					</span>
                </div>
        </div>
		<div ng-if="pagedata.post.sendtype!=1" class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label">联系人</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input ng-model="pagedata.post.username" class="weui_input" type="text" placeholder="请输入联系人">
                </div>
        </div>
		<div ng-if="pagedata.post.sendtype!=1" class="weui_cell">
                <div class="weui_cell_hd"><label class="weui_label">联系电话</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input ng-model="pagedata.post.mobile" class="weui_input" type="text" placeholder="请输入电话">
                </div>
        </div>
		<div ng-if="pagedata.post.sendtype==1" class="weui_cell">
                <div class="weui_cell_hd weui_cell_primary"  style="padding:0.3rem 0">
                    <span>配送费用</span>
                </div>
                <div class="weui_cell_ft">{{pagedata.post.peisongfee}}元</div>
        </div>
		</div>
		<div class="weui_btn_area">																			
			 <a ng-if="!pagedata.order_id" class="weui_btn weui_btn_primary" href="javascript:" id="showTooltips" ng-click="pagedata.pay()">确认支付{{pagedata.showprice}}</a>
			 <a ng-if="pagedata.order_id" class="weui_btn weui_btn_primary" href="javascript:" id="showTooltips" ng-click="access_json('jy_farmer/order//type=animal_list')">查看订单</a>
		</div>
		</div>
</div>
</div>
<div ng-include="sys_html('_footer')"></div>
<script>
window.scope.location(function(re){
	var pcd = scope.pagedata.post.pcd
	if(!pcd || pcd =='' || !pcd.province){
		scope.pagedata.post.pcd.province = re.addressComponents.province
		scope.pagedata.post.pcd.city = re.addressComponents.city
		scope.pagedata.post.pcd.district = re.addressComponents.district
		scope.$evalAsync();
	}
});
scope.pagedata.getprovince=function(){
	scope.get('jy_weishop/get_data/getprovince/',function(res){
		scope.pagedata.province=res.province;
		scope.$evalAsync();
	});
}
scope.pagedata.getprovince();
</script>
<script type="text/javascript">
	scope.getdata = function(id,timeid){
		var params1 = {
					'plugin':'jy_farmer',
					'action':'buyanimal',
					'op':'money',
					'query':'id='+id+'&time='+timeid,
					'data':{},
					'callback':function(data){
							console.log(data)
							if(data.success == 1){
								scope.$apply(function(){
									scope.pagedata.money = data.money;
								});
							}
					}
		}
		scope.post_json(params1);
}
//刷新总数和总价
scope.pagedata.cart_refresh=function(){
	scope.pagedata.totalprice=scope.pagedata.animal.price*scope.pagedata.post.total;
	if(scope.pagedata.post.sendtype==1 && scope.pagedata.totalprice){
		scope.pagedata.totalprice +=scope.pagedata.post.peisongfee*1;
	}
	scope.pagedata.showprice=scope.price(scope.pagedata.totalprice);
	scope.$evalAsync();
}
scope.pagedata.cart_refresh();
//减少
scope.pagedata.cart_minus=function(){
	if(scope.pagedata.post.total<=1){
		return false;
	}
	scope.pagedata.post.total--
	scope.pagedata.up_peisong();
}
//增加
scope.pagedata.cart_plus=function(g){
	scope.pagedata.post.total++
	scope.pagedata.up_peisong();
}
scope.pagedata.pay=function(){
	scope.post_json('jy_farmer/buyanimal/notice/',scope.pagedata.post,function(result){
		scope.pagedata.order_id=result.order_id;
		scope.$evalAsync();
		scope.tool.pay(result.pay_id,function(res){
				if(res.type=='success'){
					scope.message('支付成功！','success','jy_farmer/myanimal/');
				}else{
					scope.message('支付失败！','success','jy_farmer/order//type=animal_list');
				}
		},'','','jy_farmer/order//type=animal_list');
	});

}
//更新运费
scope.pagedata.up_peisong=function(){
		scope.get('jy_farmer/get_data/get_freight/showbaoyou=1&addressid='+scope.pagedata.post.addressid+'&total='+scope.pagedata.post.total,function(freight){
				console.log('freight');console.log(freight);
				//console.log('addressid');console.log(scope.pagedata.post.addressid);
				scope.pagedata.post.endprice=parseFloat(scope.pagedata.post.endprice)-parseFloat(scope.pagedata.post.dispatchprice)+parseFloat(freight.fee);
				scope.pagedata.post.dispatchprice=freight.fee;
				scope.pagedata.post.peisongfee=scope.pagedata.post.dispatchprice
				scope.pagedata.post.addbaoyoufee=freight.addbaoyoufee;
				scope.pagedata.post.isonebaoyou=freight.isonebaoyou;
				scope.pagedata.edit_address=0;
				scope.pagedata.modal_address=0;
				scope.pagedata.post.outarea=freight.outarea;
				scope.pagedata.post.no_out_price=freight.no_out_price?freight.no_out_price:0;
				scope.pagedata.post.baoyou_man=freight.baoyou_man?freight.baoyou_man:0;
				scope.pagedata.post.peisong_juli=freight.juli?freight.juli:scope.pagedata.post.peisong_juli;
				scope.pagedata.cart_refresh();
			});
}
</script>